package com.chinasofti.SSM.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.chinasofti.SSM.pojo.User;
import com.chinasofti.SSM.tools.Constants;

public class SysInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		
		User user = (User)request.getSession().getAttribute(Constants.USER_SESSION);
		
		if(user == null) {
			response.sendRedirect(request.getContextPath()+"/401.jsp");
			return false;
		}
		
		return true;
	}

}
